class Solution {
public:
    int jump(vector<int>& nums) {
        //依旧是在我所有可能的选择中选择能够跳跃的最长的长度，这样一定是最少的跳跃次数
        int ret = 0;
        int left = 0;
        int right = 0;
        int maxwindow = 0;
        while(left<=right)
        {
            if(maxwindow>=nums.size() - 1)
            {
                return ret;
            }
            for(int i = left;i<=right;i++)
            {
                maxwindow = max(maxwindow,i+nums[i]);
            }
            ret++;
            left = right+1;
            right = maxwindow;
        }
        return ret;
    }
};